<template>
	<view>
		<apply-grid :title="`常用${type}`" :list="usedList" :bgJson="bgJson" :editBtn="0"></apply-grid>
		<apply-grid :title="`所有${type}`" :list="allList" :selApply="usedList" :bgJson="bgJson" :editBtn="1"></apply-grid>
	</view>
</template>

<script>
	import ApplyGrid from './components/apply-grid.vue'
	
	export default {
		components: {
			ApplyGrid
		},
		data() {
			return {
				usedList: [],
				allList: [],
				bgJson: false,
				type: ''
			}
		},
		methods: {
			
		},
		onLoad(option) {
			if (option.type == 0) {
				let _used_apply_key = ['打卡', '吃饭', '重点工作']
				this.type = '应用'
				this.bgJson = true
				this.usedList = this.$store.state.vuex_used_apply||[]
				this.allList = this.$store.state.vuex_user.menuList||[]
			} else if (option.type == 1) {
				let _used_work_key = ['请假申请', '休班申请', '公出申请', '补签申请']
				this.type = '工作'
				this.bgJson = false
				
				this.usedList = this.$store.state.vuex_used_work||[]
				this.allList = this.$store.state.vuex_user.flowFormList||[]
			}
			uni.setNavigationBarTitle({
			    title: `编辑常用${this.type}`
			})
		},
		onUnload() {
			if (this.type === '工作') {
				this.$u.vuex('vuex_used_work', this.usedList)
			} else if (this.type === '应用') {
				this.$u.vuex('vuex_used_apply', this.usedList)
			}
		}
	}
</script>

<style>

</style>
